<template>
  <div>
    <script id="editor" type="text/plain"></script>
  </div>
</template>

<script>
export default { // 装载这个 babel-plugin-transform-remove-strict-mode  去掉报的argument callee bug
  name: 'UE',
  data () {
    return {
      editor: null,
      setContentSave: null
    }
  },
  props: {
    defaultMsg: {
      type: String
    },
    config: {
      type: Object
    }
  },
  mounted () {
    this.ue = UE.getEditor('editor', {
      autoHeight: true
    })
    this.isInit = false
    this.ue.ready(() => {
      this.isInit = true
      if (this.setContentSave) {
        this.ue.setContent(this.setContentSave)
        console.log(11, this.ue.getContent())
      }
    })
  },
  methods: {
    getContent (arg) {
      return arg ? this.ue.getContentTxt() : this.ue.getContent()
    },
    getContentTxt () {
      return this.ue.getContentTxt()
    },
    setContent (content) {
      if (this.isInit) {
        this.ue.setContent(content)
      } else {
        this.setContentSave = content
      }
    }
  },
  destroyed () {
    this.ue.destroy()
  }
}
</script>
